module.exports.hotTop = hotTop;
const mysql = require('mysql');
const pool = mysql.createPool({
    connectionLimit: 1000,
    host: 'localhost',
    user: 'root',
    password: '123456',
    database: 'meishi',
})

function selectPois(arrPoi) {
    let pois = [];
    arrPoi.forEach(async(element) => {
        let poi = await selectOnePoi1(poiId);
        pois.push(poi);
    });
    return pois;
}

function selectOnePoi1(poiId) {
    return new Promise((resolve, reject) => {
        pool.query(`SELECT * FROM storeurl_6549 WHERE poiId = ${poiId}`, function(err, res, fie) {
            if (res) { console.log(res) };
            resolve(res[0]);
        })
    })

}

/**
 * 根据 poiId 来查询店铺信息,返回店铺的介绍信息 
 * @param {*} poiId 
 */
async function selectOnePoi(poiId) {
    let res = await selectOnePoi1(poiId);
}

function hotTop1(N) {
    return new Promise((resolve, rej) => {
        pool.query(`SELECT * FROM storeurl_6549 ORDER BY allCommentNum DESC LIMIT 0,${N}`, function(err, res, fie) {
            if (res) resolve(res);
        })
    })
};

async function hotTop(N) {
    let pois = await hotTop1(N);
    console.log(pois)
    return pois;
}

hotTop(10);

// selectPois([193993756,1261244583,193379848,184444784])

selectOnePoi(100144804);